package com.bos.util;

/**
 * Created by IntelliJ IDEA.
 * User: Latief
 * Date: 5/26/11
 * Time: 5:09 PM
 * To change this template use File | Settings | File Templates.
 */
public final class NumberUtil {

    public static String convertToNumberSeparator(int number){
        String numberString = number+"";
        String numberSeparator = "";
        int digit = 0;
        for(int i=numberString.length()-1; i >=0; i--){
            numberSeparator = numberString.charAt(i)+ numberSeparator;
            if(digit == 2 && numberString.charAt(i) != '-'){
                numberSeparator = "." + numberSeparator;
                digit = 0;
                continue;
            }

            digit++;
        }

        return numberSeparator;
    }

    public static String convertToNumberSeparator(long number){
        String numberString = number+"";
        String numberSeparator = "";
        int digit = 0;
        for(int i=numberString.length()-1; i >=0; i--){
            numberSeparator = numberString.charAt(i)+ numberSeparator;
            if(digit == 2 && numberString.charAt(i) != '-'){
                numberSeparator = "." + numberSeparator;
                digit = 0;
                continue;
            }

            digit++;
        }

        return numberSeparator;
    }

}
